home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_2 / mbench / install-mbench < prev    next >
Text File  |  1980-12-31  |  12KB  |  481 lines

  1. ; $VER: MBench install 1.0
  2. ; English language
  3. ;
  4. ;
  5. ; Copyright (C) Mark Hewitt.
  6. ;
  7. ; Set TABS to 4
  8. ;
  9. ; BUGS
  10. ;  Problems when there is already a version of MBench installed.
  11.  
  12. ;
  13. ; First we have the text strings for translation.
  14.  
  15. ;-----------------------------------------------------------------
  16. ; ### variable declarations
  17. (set #ProgName "MBench")
  18. (set #DiskName "MBench")
  19. (set #HDSpaceNeededBytes (* (* 1 1024) 300)) ; 300K Free
  20. (set #ImagesDest "SYS:Classes/Images")
  21.  
  22. ;-----------------------------------------------------------------
  23. ; ### string declaration
  24. ;// Drawer names
  25. (set #DrawerName "MBench")
  26. (set #StartMenuDrawerName "StartMenu")
  27. (set #WorkspaceDrawerName "WorkSpace")
  28. (set #ModulesDrawerName   "Modules")
  29. (set #ExtrasDrawerName        "Extras")
  30.  
  31. ;// File names
  32. (set #HelpFileName "MBench.Guide")
  33. (set #ReadMeName   "ReadMeFirst")
  34. (set #OrderFormName "OrderForm")
  35.  
  36. ;-----------------------------------------------------------------
  37. ;// Message strings
  38. (set #CheckStartup
  39.     (cat "\n\n\nPlease wait...\n\nThe installer is just checking your system.")
  40. )
  41.  
  42. (set #WorkingMsg (cat "Please wait...\n\nInstalling " #ProgName))
  43.  
  44. (set #BadKick
  45.     (cat #ProgName " requires Workbench 2.04 or above to work correctly.")
  46. )
  47.  
  48. (set #introduction
  49.     (cat    "Welcome to the MBench installation procedure.\nThis utility will"
  50.         "enable you to simply install MBench onto your system.\n"
  51.         "Simply follow the instructions and click help for more information at any stage."
  52.     )
  53. )
  54.  
  55.  
  56.  
  57. (set #DestChoicePrompt
  58.     (cat "\n\n\nWhere would you like to install " #ProgName "?")
  59. )
  60. (set #HardDiskDestChoiceMsg
  61.     (cat "Where do you want to install the\n" #ProgName " drawer?")
  62. )
  63. (set #HardDiskDestChoiceHelp
  64.     (cat "Select the drawer where you want to install " #ProgName
  65.         ", then click Proceed (a new drawer titled \"" #DrawerName
  66.         "\" will be created and will contain the " #ProgName " program.)"
  67.     )
  68. )
  69.  
  70.  
  71. (set #NoDiskSpaceMsg1
  72.     (cat "\nThere is insufficient available space on your hard disk to install "
  73.         #ProgName ". You will need a minimum of "
  74.     )
  75. )
  76. (set #NoDiskSpaceMsg2
  77.     (cat "MB of free disk space.\n\nEither click \"Abort Install\" to exit this "
  78.         "installation and delete some files from your hard disk, or click \"Proceed\" and try a "
  79.         "different partition."
  80.     )
  81. )
  82.  
  83.  
  84. (set #DrawerExistsMsg
  85.     (cat "\nA drawer titled \"" #DrawerName "\" already exists in "
  86.         "the destination you have chosen.\n\nDo you wish to replace it "
  87.         "or choose a new destination?\n\n"
  88.     )
  89. )
  90. (set #DrawerExistsChoice1 "Replace it")
  91. (set #DrawerExistsChoice2 "Choose new destination")
  92. (set #DrawerExistsHelp
  93.     (cat "\nYou have chosen a destination drawer which already has \""
  94.         #DrawerName "\" installed there.\n\nClick \""
  95.         #DrawerExistsChoice1 "\" to replace the contents with this new version "
  96.         "of " #ProgName ".\nClick \"" #DrawerExistsChoice2 "\" to choose a "
  97.         "new destination drawer.\n\n"
  98.         "If you choose \"" #DrawerExistsChoice1 "\" then please make sure you "
  99.         "have back up copies of any documents you wish to keep."
  100.     )
  101. )
  102.  
  103.  
  104.  
  105. (set #SelectStartMenuIcons "Which icons do you want for the start menu?")
  106. (set #StandardMenuItems    "Standard Icons")
  107. (set #MagicMenuItems    "Magic Menu Icons")
  108. (set #StartMenuIconsHelp 
  109.     (cat "If you have Magic Menus installed then it is best to install"
  110.         "the modified Magic Menu Icons. \nIt is also an idea to "
  111.         "Change in the settings the Misc/Show StartMenu Arrows item"
  112.         "so that the arrows for sub menus don't look strange."
  113.     )
  114. )
  115.  
  116.  
  117.  
  118. (set #AskUserStartUpMsg
  119.     (cat "For " #ProgName " to work properly, some assigns have to be added "
  120.         "to your 'user-startup' script:\n\n Click proceed to continue."
  121.     )
  122. )
  123.  
  124.  
  125. (set #AskUserStartUpHelp
  126.     (cat "For MBench to work correctly it needs to set up the assigns"
  127.          "'MBench:' and 'WorkSpace:'.\n\n"
  128.          "Click Proceed if you want the installer to do this automatically, "
  129.          "or click 'Skip This Part' to not modify the user-startup."
  130.     )
  131. )
  132.  
  133.  
  134.  
  135.  
  136.  
  137. ;------------------------------------------------------
  138. ; ### Procedure declarations
  139.  
  140. ;------------------------------------------------------
  141. ; ### First some general routines.
  142.  
  143.  
  144. ;------------------------------------------------------
  145. ;// Initial Checks
  146. (procedure @InitialChecks
  147. (
  148.     ;// Check OS version
  149.     (working #CheckStartup)
  150.  
  151.     (set #OSVerNum (getversion))
  152.     (set #OSVersion (/ #OSVerNum 65536))
  153.  
  154.     (if (< #OSVersion 37)
  155.         (abort #BadKick)
  156.     )
  157.  
  158.     ; Set this here as in some instances we need to get a response from the
  159.     ; user if the worst comes to the worse and change mode to something
  160.     ; else to get an input. See @ChooseHDDest for an example.
  161.     (set #UserNovice 0)
  162.     (if (= @user-level 0)
  163.     (
  164.         (set #UserNovice 1)
  165.     )
  166.     )
  167. )
  168. )
  169.  
  170.  
  171.  
  172.  
  173. ;### Choose hard disk destination for MBench
  174. (procedure @ChooseHDDest
  175. (
  176.     ;** Find default drawer
  177.     (set #DefaultDest (getassign "Work" "d"))
  178.     (if (= #DefaultDest "")
  179.     (
  180.         (set #DefaultDest (getassign "HD3" "d"))
  181.         (if (= #DefaultDest "")
  182.         (
  183.             (set #DefaultDest (getassign "HD2" "d"))
  184.             (if (= #DefaultDest "")
  185.                (
  186.                 (set #DefaultDest (getassign "HD1" "d"))
  187.                 (if (= #DefaultDest "")
  188.                 (
  189.                     (set #DefaultDest (getassign "DH1" "d"))
  190.                     (if (= #DefaultDest "")
  191.                     (
  192.                         (set #DefaultDest (getassign "HD0" "d"))
  193.                         (if (= #DefaultDest "")
  194.                         (
  195.                             (set #DefaultDest "DH0:")
  196.                             (if (= #DefaultDest "")
  197.                             (
  198.                                 ; ## No default available so force to select one.
  199.                                 (if (= #UserNovice 1)
  200.                                   (user 2)
  201.                                 )
  202.                             )
  203.                             )
  204.                         )
  205.                         )
  206.                     )
  207.                     )
  208.                 )
  209.                 )
  210.             )
  211.             )
  212.         )
  213.         )
  214.     )
  215.     )
  216.  
  217.     ;** Ask for destination the destination drawer.
  218.     (set #DestDrawer
  219.         (askdir
  220.             (prompt #HardDiskDestChoiceMsg)
  221.             (help #HardDiskDestChoiceHelp)
  222.             (default #DefaultDest)
  223.         )
  224.     )
  225.  
  226.     ;## incase we were forced to change mode above, change back.
  227.     (if (= #UserNovice 1)
  228.         (user 0)
  229.     )
  230. )
  231. )
  232.  
  233.  
  234.  
  235. ;------------------------------------------------------
  236. ;### Procedure to check if MBench exists already in destination
  237. ;### Replace or choose again if so
  238. (procedure @CheckExistsAlready
  239. (
  240.     (if (exists (tackon #DestDrawer #DrawerName))
  241.     (
  242.         (set ChooseAgainAnswer
  243.             (askbool
  244.                 (prompt #DrawerExistsMsg)
  245.                 (choices #DrawerExistsChoice1 #DrawerExistsChoice2)
  246.                 (help #DrawerExistsHelp)
  247.                 (default 1)
  248.             )
  249.         )
  250.         (if (= ChooseAgainAnswer 0)
  251.         (
  252.             (set MMExists 0)
  253.         )
  254.         (
  255.             (set MMExists 1)
  256.         )
  257.         );endif
  258.     )
  259.     (;else
  260.         (set MMExists 1)
  261.     )
  262.     );endif
  263. )
  264. )
  265.  
  266. ;------------------------------------------------------
  267. ;### Find HD Destination and check enough space
  268. (procedure @FindHDDest
  269. (
  270.     ;## loop untill we get a drawer that doesn't already exist.
  271.     (set MMExists 0)
  272.     (while (= MMExists 0)
  273.     (
  274.           (@ChooseHDDest)
  275.         (while (< (getdiskspace #DestDrawer) #HDSpaceNeededBytes)
  276.            (
  277.               (if (< (getdiskspace #DestDrawer) #HDSpaceNeededBytes)
  278.                (
  279.                 ; ## if there was an error we must change mode to try and
  280.                 ; ## get the user to rectify the problem.
  281.                 (if (= @user-level 0)
  282.                   (
  283.                     (user 2)
  284.                     (set #UserNovice 1)
  285.                 )
  286.                 )
  287.                   (message #NoDiskSpaceMsg1 (/ (/ #HDSpaceNeededBytes 1024) 1024) #NoDiskSpaceMsg2)
  288.                  (@ChooseHDDest)
  289.                )
  290.                 )
  291.            )
  292.            ) ;end while
  293.  
  294.         ;## check if it already exists.
  295.         (@CheckExistsAlready)
  296.     )
  297.     );end while
  298.  
  299.     ;## incase we were forced to change mode above, change back.
  300.     (if (= #UserNovice 1)
  301.         (user 0)
  302.     )
  303. )
  304. )
  305.  
  306.  
  307.  
  308.  
  309. ;------------------------------------------------------
  310. ;### And some specific routines.
  311.  
  312. ;
  313. ;// Create any drawers that are necessary.
  314. (procedure @CreateDrawers
  315. (
  316.     (working #WorkingMsg)
  317.  
  318.     ;// Make the main MBench drawer
  319.     (set #InsideHDDest (tackon #DestDrawer #DrawerName))
  320.     (makedir #InsideHDDest (infos))
  321. )
  322. )
  323.  
  324.  
  325.  
  326. ;
  327. ;// And install all files.
  328. (procedure @InstallFiles
  329. (
  330.     (working #WorkingMsg)
  331.  
  332.     ;### And install all the files.
  333.     ; First MBench
  334.     (copyfiles
  335.         (source "")
  336.             (choices #ProgName #HelpFileName #ReadMeName #OrderFormName "AddToStartSequence" #ModulesDrawerName #WorkSpaceDrawerName )
  337.             (dest #InsideHDDest)
  338.         (infos)
  339.             (optional "force")
  340.         )
  341.  
  342.  
  343.  
  344.     ; set which start menu items we want to use.
  345.         (set ChooseAgainAnswer
  346.         (askbool
  347.                     (prompt #SelectStartMenuIcons)
  348.                 (choices #MagicMenuItems #StandardMenuItems)
  349.                     (help #StartMenuIconsHelp)
  350.                 (default 0)
  351.             )
  352.         )
  353.         (if (= ChooseAgainAnswer 0)
  354.         (
  355.         (copyfiles
  356.             (source "")
  357.                 (choices "StartMenuStandard")
  358.                 (dest #InsideHDDest)
  359.             (infos)
  360.                 (optional "force")
  361.             )
  362.         (rename (tackon #InsideHDDest "StartMenuStandard") (tackon #InsideHDDest "StartMenu"))
  363.         (rename (tackon #InsideHDDest "StartMenuStandard.info") (tackon #InsideHDDest "StartMenu.info"))
  364.         ))
  365.         (if (= ChooseAgainAnswer 1)
  366.         (
  367.         (copyfiles
  368.             (source "")
  369.                 (choices "StartMenuMagicMenu")
  370.                 (dest #InsideHDDest)
  371.             (infos)
  372.                 (optional "force")
  373.             )
  374.         (rename (tackon #InsideHDDest "StartMenuMagicMenu") (tackon #InsideHDDest "StartMenu"))
  375.         (rename (tackon #InsideHDDest "StartMenuMagicMenu.info") (tackon #InsideHDDest "StartMenu.info"))
  376.         ))
  377.  
  378.  
  379.     ; And the prefs program.
  380.     (copyfiles
  381.         (source "MBPrefs")
  382.             (dest "sys:Prefs")
  383.         (infos)
  384.     )
  385.  
  386.  
  387.     ; Now all libraries
  388.     (copylib
  389.         (source "libs/mbmisc.library")
  390.             (dest "LIBS:")
  391.     )
  392.  
  393.  
  394.     ; Now copy files to other places, such as the images and 'C:' commands
  395.     ; First do the images.
  396.     (if (NOT (exists "ram:classes" (noreq) ))
  397.         (makedir "ram:Classes" (infos))
  398.     )
  399.     (if (NOT (exists "ram:classes/images" (noreq) ))
  400.         (makedir "ram:Classes/Images" (infos))
  401.     )
  402.     (copyfiles
  403.         (source "Images")
  404.         (all)
  405.             (dest "ram:Classes/Images")
  406.         (infos)
  407.             (optional "force")
  408.     )
  409.  
  410.  
  411.     ; And the c commands.
  412.     (copyfiles
  413.         (source "Utilities/MBCommand")
  414.             (dest "C:")
  415.         (infos)
  416.             (optional "force")
  417.     )
  418.  
  419.  
  420.     ; delete old config files.    
  421.     (delete "ENV:sys/mbench.config")
  422.     (delete "ENVARC:sys/mbench.config")
  423.  
  424.  
  425.     ; now set any startup-sequence assigns etc.
  426.     ;Set up any assigns
  427.     (startup #ProgName
  428.         (prompt #AskUserStartUpMsg)
  429.         (help #AskUserStartUpHelp)
  430.         (command (cat"C:Assign >NIL: MBench: " #InsideHDDest "\n"))
  431.         (command (cat"C:Assign >NIL: WorkSpace: " #WorkSpaceDest "\n"))
  432.     )
  433.  
  434.     (run (cat "Assign >NIL: MBench: " #InsideHDDest))
  435.     (run (cat "Assign >NIL: WorkSpace: " #WorkSpaceDest))
  436.  
  437.     ; NOTE THAT WE CHANGE USER MODE HERE to always get a response!!!!! 
  438.     (user 2)
  439.     (set ChooseAgainAnswer
  440.         (askbool
  441.                 (prompt "Do you want MBench automatically run on start up instead of Workbench?")
  442.                 (help (cat "If you like MBench then why not have it run on start up every time. "
  443.                   "If you select yes then it will remove the old lines from the "
  444.                   "S:Startup-Sequence and add a line to run MBench instead.\n"
  445.                   "If you would just like to test MBench first instead then select no "
  446.                   "and if you change your mind later then just run the AddToStartSequence "
  447.                   "program to automatically run it at a later date.\n"))
  448.             (default 0)
  449.         )
  450.     )
  451.     (if (= ChooseAgainAnswer 1)
  452.     (
  453.             (run "MBench:AddToStartSequence")
  454.     )
  455.     );endif
  456. )
  457. )
  458.  
  459.  
  460.  
  461. ;------------------------------------------------------
  462. ; ### Main
  463. (complete 0)
  464. (welcome)
  465. (message #introduction)
  466. (complete 5)
  467.  
  468.     ;### gets a dest and makes sure that there is enough space and that either
  469.     ;### it doesn't already exist or it is OK to overwrite it.
  470.     (@FindHDDest)
  471. (complete 20)
  472.  
  473.     ;### makes the actual drawers.
  474.     (@CreateDrawers)
  475.     (set @default-dest #DestDrawer)
  476. (complete 30)
  477.  
  478.     ;### and copy the files over.
  479.     (@InstallFiles)
  480. (complete 100)
  481. (exit)